﻿<!DOCTYPE HTML>
<html>
{include file='public/head'}
<body>
<style>
	.pager{
		margin: 0 auto;
		width: 50px ;
        overflow:hidden;
		font-size:30px;
	}
	.pager li:first-child{
		float: left;

	}
	.pager li:last-child{
		float:right;
	}
</style>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 学生管理 <span class="c-gray en">&gt;</span> 学生列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		<form action="{:url('admin/student/studentlist')}" method="post">
		<input type="text" class="input-text" style="width:250px" placeholder="输入学生名称" id="name" name="name">
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
		</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20" style="float: left;">
		<span class="l"> <a href="javascript:;" onclick="admin_add('添加管理员','{:url(\"admin/student/studentadd\")}','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 手动添加学生</a></span>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20" style="float: left;">
		<a href="javascript:;" onclick="admin_excel('下载','{:url(\"admin/student/studentexceldown\")}','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 下载学生信息</a></span>
	</div>
	<div style="clear: both"></div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="9">学生列表</th>
			</tr>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="80">姓名</th>
				<th width="80">班级号</th>
				<th width="80">课程</th>
				<th width="80">阶段</th>
				<th width="80">老师</th>
				<th width="80">留级</th>
				<th width="80">成绩详情</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
		{volist name='student' id='vo'}
			<tr class="text-c">
				<td>{$vo.id}</td>
				<td>
					<a href="javascript:;" onclick="details('详情','{:url(\"admin/student/details\")}','{$vo.id}','800','500')" ">{$vo.student_name}</a>
				</td>
				<td>{$vo.classroom.class_name}</td>
				{if condition='$vo.classroom.subject==1'}
				<td>全栈</td>
				{else if}
				<td>前端</td>
				{/if}
				{switch vo.classroom.stage}
				{case 1}<td>初级</td>{/case}
				{case 2}<td>中级</td>{/case}
				{case 3}<td>高级</td>{/case}
				{/switch}
				<td>{$vo.teacher.name}</td>
				<td>
					<a href="javascript:;" onclick="student_down('{$vo.id}')" class="btn btn-primary radius">
					<i class="Hui-iconfont"></i> 留级
					</a>
				</td>
				<td>
					<a href="javascript:;" onclick="ScoreDetails('成绩详情','{:url(\"admin/score/ScoreDetails\")}','{$vo.id}','800','400')" class="btn btn-primary radius">
					<i class="Hui-iconfont"></i>成绩详情
				</td>
				<td class="td-manage">
					<a style="text-decoration:none" onClick="admin_stop(this,'10001')" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>
					<a title="编辑" href="javascript:;" onclick="admin_edit('管理员编辑','{:url(\"admin/student/studentedit"\)}','{$vo.id}','800','500')" class="ml-5" style="text-decoration:none">
					<i class="Hui-iconfont">&#xe6df;</i>
					</a>
					<a title="删除" href="javascript:;" onclick="admin_del(this,'{$vo.id}')" class="ml-5" style="text-decoration:none">
						<i class="Hui-iconfont">&#xe6e2;</i>
					</a>
				</td>
			</tr>
		{/volist}
		</tbody>
	</table>
	{if $Think.session.auth['aid'] == 32}
		{$page}
		{/if}
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
{include file='public/foot'}<!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
/*
	参数解释：
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/
function student_up(id){
    var urls = '{:url("admin/student/chooseclassroom")}';
    $.ajax({
        type:'post',
        data:{'id':id},
        dataType:'json',
        url:'{:url("admin/student/studentup")}',
        success:function (data) {
            if (data.status == 1) {
                layer.msg(data.msg, {icon: 1, time: 1000,});
                layer_show('选择班级',urls+'?id='+id,500,200);
            } else {
                layer.msg(data.msg, {icon: 2, time: 1000});
            }
        },
    })
}
/**
 * 	学生搜索
 * */
// function seach(){
//     var name = $('#name').val();
//     $.ajax({
// 		type:'post',
// 		data:{'name':name},
// 		dataType:'json',
// 		url:'{:url("admin/student/studentseach")}',
//         success:function (data) {
//             if (data.status == 1) {
//                 layer.msg(data.msg, {icon: 1, time: 1000,});
//             } else {
//                 layer.msg(data.msg, {icon: 2, time: 1000});
//             }
//         },
// 	})
// }
function ScoreDetails(title,url,id,w,h) {
    layer_show(title,url+'?id='+id,w,h);
}

function student_down(id){
    var urls = '{:url("admin/student/chooseclassroom")}';
    $.ajax({
        type:'post',
        data:{'id':id},
        dataType:'json',
        url:'{:url("admin/student/studentdown")}',
        success:function (data) {
            if (data.status == 1) {
                layer.msg(data.msg, {icon: 1, time: 1000,});
                layer_show('选择班级',urls+'?id='+id,500,200);
            } else {
                layer.msg(data.msg, {icon: 2, time: 1000});
            }
        },
    })
}

function details(title,url,id,w,h){
    layer_show(title,url+'?id='+id,w,h);
}
/*管理员-增加*/
function admin_add(title,url,w,h){
	layer_show(title,url,w,h);
}
function admin_excel(title,url,w,h){
    window.location.href = url;
}
/*管理员-删除*/
function admin_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '{:url("admin/student/StudentDel")}',
			dataType: 'json',
			data:{id:id},
			success: function(data){
			    if (data.status == 1){
                    $(obj).parents("tr").remove();
                    layer.msg(data.msg,{icon:1,time:1000});
				} else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
				}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
/*管理员-编辑*/
function admin_edit(title,url,id,w,h){
    layer_show(title,url+'?id='+id,w,h);
}

/*管理员-停用*/
function admin_stop(obj,id){
	layer.confirm('确认要停用吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		
		$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_start(this,id)" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已禁用</span>');
		$(obj).remove();
		layer.msg('已停用!',{icon: 5,time:1000});
	});
}

/*管理员-启用*/
function admin_start(obj,id){
	layer.confirm('确认要启用吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_stop(this,id)" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
		$(obj).remove();
		layer.msg('已启用!', {icon: 6,time:1000});
	});
}

function page() {
	var pageUp = $('.pager li:nth-child(1) a');
	var pageDown = $('.pager li:nth-child(2) a');
	pageUp.attr('title','上一页');
    pageDown.attr('title','下一页');
}
page();
</script>
</body>
</html>